#include<iostream>
#include<string>
#include<sstream>
#include<fstream>
#include<vector>
using namespace std;
class MergeS{
	public:
		MergeS(){}
		//两个有序序列二路归并
		void Merge(vector<int>&v,int low,int mid,int high){
			vector<int>v1;
			v1.resize(high-low+1);
			int i=low;
			int j=mid+1;
			int k=0;
			while(i<=mid && j<=high){ //从第1段开头和第2段开头进行二路归并
				if(v[i]<=v[j]){ //把小的放入v1
					v1[k]=v[i];
					i++;
					k++;
				}
				else{
					v1[k]=v[j];
					j++;
					k++;
				}
			}
			while(i<=mid){ //第1段有剩余，直接放入v1
				v1[k]=v[i];
				k++;
				i++;
			}
			while(j<=high){ //第2段有剩余，直接放入v1
				v1[k]=v[j];
				k++;
				j++;
			}
			for(int n1=low,n2=0;n1<=high;n1++,n2++){
				v[n1]=v1[n2];
			}
		}
		
		//递归进行二路归并，从底向上
		void MergePass(vector<int>&v,int len){
			int n=v.size();
			int i=0;
			for(;i+2*len-1<n;i+=2*len){ //i为low,i+2*len-1即从i开始两个长为len的子表末尾的high
				Merge(v,i,i+len-1,i+2*len-1);
			}
			if(i+len<n){ //末尾剩下的长度小于len
				Merge(v,i,i+len-1,n-1);
			}
		}
};
int main(){
	ifstream infile("in.txt");
	string line;
	getline(infile,line);
	int d=0;
	vector<int>data;
	stringstream ss(line);
	while(ss>>d){
		data.push_back(d);
	}
	infile.close();
	
	MergeS ms;
	for(int l=1;l<data.size();){
		ms.MergePass(data,l);
		l=l*2;
	}
	
	ofstream outfile("out.txt",ofstream::out | ofstream::trunc);
	for(int i=0;i<data.size();i++){
		outfile<<data[i]<<" ";
	}
	outfile.close();
	return 0;
}